/**
 * @Project TMHSCFX
 * @Author Tran Manh Hung
 * @Email: hungtmit@gmail.com | tmh@xwebgate.com
 * @Copyright © 2011 TMH. All rights reserved
 * @Createdate Apr 13, 2011
 * @Createtime 10:03:21 PM
 */

package com.tmh.study.fAS3AMTM.chap4
{
	import flash.display.GradientType;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Matrix;

	public class GradientFill2 extends Sprite
	{
		public function GradientFill2()
		{
			super();
			addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
		}

		private function addedToStageHandler(event:Event):void
		{
			initData();
		}

		private function initData():void
		{
			graphics.lineStyle(1, 0xcc0000);
			var colors:Array = [0xffffff, 0x00ff00, 0xff0000];
			var alphas:Array = [1, 1, 1];
			var ratios:Array = [0, 128, 255];
			var matrix:Matrix = new Matrix();
			matrix.createGradientBox(100, 100, 0, 100, 100);
			graphics.beginGradientFill(GradientType.RADIAL, colors, alphas, ratios, matrix);
			graphics.drawRect(100, 100, 100, 100);
			graphics.endFill();
		}
	}
}